package com.itheima.HomeWork;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class ddd {
    public static void main(String[] args) throws IOException {
        File f1 = new File("E:\\img1\\aa");
        File f2 = new File("E:\\img1\\bb");
        co(f1, f2);
    }

    public static void co(File f1, File f2) throws IOException {
        f2.mkdir();
        File[] files = f1.listFiles();
        for (File file : files) {
            if (file.isFile()) {
                FileInputStream fis = new FileInputStream(file);
                FileOutputStream fos = new FileOutputStream(new File(f2, file.getName()));
                int lne;
                byte[] bay = new byte[1024];
                while ((lne = fis.read(bay)) != -1) {
                    fos.write(bay,0,lne);
                }
                fis.close();
                fos.close();
            } else {
                co(file, new File(f2, file.getName()));
            }
        }
    }
}
